<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html >
<html lang="en">
<head>
<%@include file="../../../common/includeBaseSet.jsp" %>
<%@include file="../../../common/includeSystemSet.jsp" %>
<%@include file="../../../common/operation_forbid.jsp" %>
<%@include file="../../../common/jsVersion.jsp" %>
</head>
<body onload="loadProjectList()">
    <div class="page-content">
        <form id="baseForm" class="form-horizontal">
            <input type='hidden' class='pageNum' name='pageNum' value='1'/>
            <input type='hidden' class='pageSize' name='pageSize' value='10'/>
	        <div class="col-xs-12 panel panel-default">
	        	<div style="margin-top:1%">
		            <div class="col-xs-6">
		                <div class="form-group">
		                    <label class="col-xs-3 control-label">项目名称:</label>
		                    <div class="col-xs-6">
		                        <input name="projectName" id="projectName" type="text" class="form-control">
		                    </div>
		                </div>
		            </div>
		            <div class="col-xs-4">
		                <div class="form-group">
		                    <div>
		                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:70px;"
		                            title="查询" type="button" onclick="loadProjectList()">
		                            <i class="icon-search bigger-110 icon-only">查询</i>
		                        </button>
		                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:100px;margin-left:10px"
		                            title="生成客户问卷" type="button" onclick="questionnaire()">
		                            <i class="bigger-110 icon-only">生成客户问卷</i>
		                        </button>
		                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:100px;margin-left:10px"
		                            title="客户问卷分析" type="button" onclick="analysed()">
		                            <i class="bigger-110 icon-only">客户问卷分析</i>
		                        </button>
		                    </div>
		                </div>
		            </div>
	            </div>
	        </div>
	    </form>
        <div id="yifenpeiList" class="col-xs-12">
            <table id="baseTable" class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th class="center">&nbsp;</th>
                        <th class="center">操作</th>
                        <th class="center">项目名称</th>
                        <th class="center">最近修改时间</th>
                        <th class="center">最近修改人员</th>
                     
                    </tr>
                </thead>
                <tbody><!-- 内容 --></tbody>
            </table>
            <div class="row">
                <div class="col-sm-8">
                    <!--设置分页位置-->
                    <div id="pageing" class="dataTables_paginate paging_bootstrap">
                        <ul class="pagination"></ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- #dialog-confirm -->
        <%@include file="../../common/dialog.jsp"%>
    </div>
</body>
<script type="text/javascript">
	function loadProjectList(){
		var loadIndex = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
		JY.Ajax.doRequest("baseForm",jypath +'/system/baseCodeValue/projectList',null,function(data){
            $("#baseTable tbody").empty();
            var page = data.obj;
            //分页数据
            var pageNum = page.pageNumber, pageSize = page.pageSize, totalRecord = page.total;
            var html = "";
            var results = page.rows;
            if(results == null){
            	html+="<tr><td colspan='5' class='center'>没有相关数据</td></tr>";
                $("#baseTable tbody").append(html);
                $("#pageing ul").empty();//清空分页
                return false;
            }
            
            var leng=(pageNum-1)*pageSize;//计算序号
            for(var i = 0;i<results.length;i++){
                var info = results[i];
                var baseCodeUrl = jypath +"/system/baseCodeValue/baseCodeValueList?projectId=" + info.id;
                html += "<tr>";
                html += "<td class='center'>";
                html += "<input name='proRadio' type='radio' value='"+info.id+"' />";
                html += "</td>";
                html += "<td class='center'>";
                html += "<a href='" + baseCodeUrl + "' style='cursor:pointer'>编辑</a>";
                html += "<a onclick='copyBaseCode("+info.id+")'style='cursor:pointer;margin-left:5%'>使用其他项目选项</a>";
                html += "</td>";
                html += "<td class='center'><a href='" + baseCodeUrl + "' style='cursor:pointer'>" + info.projectName + "</a></td>";
                html += "<td class='center'>" + JY.Date.Format(info.updateTime, 'yyyy-MM-dd') + "</td>";
                html += "<td class='center'>" + info.remark + "</td>";
               
                html += "</tr>";
            }
            $("#baseTable tbody").append(html);
            JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"loadProjectList");
            layer.closeAll('loading');
		});
	}
	
	//使用其他项目选项
    function copyBaseCode(projectId){
        layer.open({
            type:2,
            title: "使用其他项目选项",
            closeBtn: 2,
            shadeClose: true,
            area: ['450px', '250px'],
            fix: false, //不固定
            content: jypath +'/system/baseCodeValue/toCopyBaseCode?projectId=' + projectId
        });
    }
	
	//生成客户问卷
	function questionnaire(){
		var val = $('input:radio[name="proRadio"]:checked').val();
        if(val == null){
            layer.alert("请选择要生成客户问卷的项目");
            return false;
        }
        
        location.href = jypath + "/system/baseCodeValue/questionnaire?projectId=" + val;
	}
	//生成客户问卷
	function analysed(){
		var val = $('input:radio[name="proRadio"]:checked').val();
        if(val == null){
        	layer.alert("请选择要生成客户问卷分析的项目");
            return false;
        }
        
        location.href = jypath + "/system/baseCodeValue/analysed?projectId=" + val;
	}
</script>
</html>